package Pessimistic;

public class Operate {
    private long count = 0;
    public void take(){
        //若不加锁处理的情况
/*        for (int i = 0; i < 100; i++) {
            System.out.println(++count);
        }*/

        //若加上锁处理的情况
        for (int i = 0; i < 100; i++) {
            synchronized (this){
                System.out.println(++count);
            }
        }
    }
}
